<?php


class baseModel {

	private $crDB;
	private $lrQuery;

	public function connect() {
		global $con_username, $con_password, $con_sid, $con_host, $con_db;
		$this->crDB = mysqli_connect($con_host, $con_username, $con_password, $con_db);
		if($this->crDB) {
			$this->crDB->set_charset("utf8");
			return TRUE;
		} else {
			return FALSE;
		}
	}

	public function __construct() {
		if(!$this->connect()) {
			die("Nepodařilo se připojit k DB");
		}
	}

	public function SimpleQuery($isSQL) {
		$lrReturn = array();
		//
		$lrResult = $this->crDB->query($isSQL, MYSQLI_USE_RESULT);
		while($lsRow = @mysqli_fetch_assoc($lrResult)) {
			$lrReturn[] = array_change_key_case($lsRow, CASE_UPPER); // fix pro kompatibilitu s Oracle
		}
		return $lrReturn;
	}

	public function RowCount($isSQL) {
		$lrResult = mysqli_query($this->crDB, $isSQL);
		return mysqli_num_rows($lrResult);;
	}

	public function __destruct() {
		mysqli_close($this->crDB);
	}

}


?>